package com.amms.android;

import java.util.ArrayList;
import java.util.List;

import com.amms.android.entities.Player;




import android.app.ListActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;

public class AndroidSoftware extends ListActivity {
	 private DBHelper dbHelper;
	 private DBHelperGeneric dbHelperGeneric;
	 private List<Player> players;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        setContentView(R.layout.main);
        dbHelper = new DBHelper(this);
        dbHelperGeneric = new DBHelperGeneric(this,Player.class,"amms","player");
        
        Player p=new Player();
        p.setAge("12");
        p.setAlias("Salaboy");
        p.setGender("Male");
        
        dbHelper.createPlayer(p.getId(), p.getAlias(),p.getAge(),p.getGender());
       
        // asi agarro los componentes definidos en el XML
      //  TextView msgTextView = (TextView)findViewById(R.id.label);
      //  msgTextView.setText(p.getAge());
        List<String> items = new ArrayList<String>();
        
        players = dbHelper.fetchAllPlayers();
        for (Player player : players) {
            items.add(player.getId()+ " - " + player.getAlias()+" - "+player.getAge()+" - "+player.getGender());
        }
      
        
        // Now create an array adapter and set it to display using our row
        ArrayAdapter<String> notes = 
            new ArrayAdapter<String>(this, R.layout.player, items);
        setListAdapter(notes);
       
    }
}